|
|
|
|
|
|
|
Call lstrcpy(ByVal OriginalName, ByVal _
NameMapping.pszOldPath)
End If
If NameMapping.cchNewPath Then
FinalName = String$(NameMapping.cchNewPath + 1, Chr$(0))
Call lstrcpy(ByVal FinalName, ByVal NameMapping.pszNewPath)
End If
lstFiles.AddItem OriginalName
lstFiles.AddItem "- renamed to -"
lstFiles.AddItem FinalName
Call SHFreeNameMappings(sh.hNameMappings)
End If
End Sub |
|
|
|
|
|
|
|
|
I still had no idea how to determine how many structures were in the array, but I was confident that, if after running the program the hNameMappings value was non-zero, at least the first entry in the array would be valid. |
|
|
|
|
|
|
|
|
The RtlMoveMemory function treats the value in the hNameMappings field as a pointer and copies it into a SHNAMEMAPPING structure named NameMapping. The cchOldPath field in the NameMapping structure contains the length of the original file name, so I initialized the OriginalName string to that length (plus 1 for the NULL terminator). The lstrcpy function in this sample program is defined as follows: |
|
|
|
|
|
|
|
|
Private Declare Sub lstrcpy Lib "kernel32" (dest As Any, src As Any) |
|
|
|
|
|
|
|
|
Both parameters are defined As Any, so the function call must explicitly include ByVal terms for both the string and Long parameters. This copies the string pointed to by the pszOldPath field into the OriginalName string. The operation is duplicated for the FinalName string. Finally, the strings are added into the list box. |
|
|
|
|
|
|
|
|
The initial results of this on my system involved the display of garbage characters in the list box. On your system, it may even crash. When I traced through the program and looked at the actual values of the four fields, I found the following results: |
|
|
|
 |
|
 |
|
|
1 Oh, you feel the hint for this chapter in Appendix A is unfair (the one that mentioned that the function is documented as running on both NT and Windows 95/98)? Well, I thought it was unfair when I discovered the documentation was wrong. That's part of the point of this puzzlewhen what you see in your own experimentation does not match the documentation, there is a very real possibility that the documentation is wrong and you are right. |
|
|
|
|
|